--3.1
select 
	id,
	first_time,
	last_time,
	--最大编号即为步长
	max(num) as count,
	--结束时间-开始时间即为浏览时长
	(unix_timestamp(last_time,'yyyy/MM/dd HH:mm') - unix_timestamp(first_time,'yyyy/MM/dd HH:mm'))/60 as duration_time
from (
	select id,
	--按id分组，求出组内开始的浏览时间
	first_value(dt) over(partition by id order by dt rows between unbounded preceding and unbounded following) as first_time,
	--按id分组，求出组内结束的浏览时间
	last_value(dt) over(partition by id order by dt rows between unbounded preceding and unbounded following) as last_time,
	--按id分组，给组内记录编号
	row_number() over(partition by id order by dt) as num 
	from t3 )tmp
group by id,first_time,last_time;